import Vue from "vue";
import VueRouter from "vue-router";
//首页
import Home from "../views/yemian/Home.vue";
//分类
import classify from "../views/yemian/classify.vue";
//购物车
import Itsmine from "../views/yemian/Itsmine.vue";
//我的
import Shoppingcart from "../views/yemian/Shoppingcart.vue";

//登录
import Login from "../views/yemian/Login.vue";

//详情页
import Details from "../views/yemian/Details.vue";

//搜索
import Search from "../views/yemian/Search.vue";
//搜索详细页
import Searchlist from "../views/yemian/Searchlist.vue";
//注册
import reg from "../views/yemian/reg.vue"
Vue.use(VueRouter);

const routes = [
  {
    path:"/",
    redirect:"/home"
  },
  {
    path: "/Home",
    name: "Home",
    meta: {
      isShow: true,
    },
    component: Home,
    meta: {
      isShow: true,
    },
  },
  {
    path: "/Itsmine",
    name: "Itsmine",
    meta: {
      isShow: true,
    },
    component: Itsmine,
    meta: {
      isShow: true,
    },
  },
  {
    path: "/classify",
    name: "classify",
    meta: {
      isShow: true,
    },
    component: classify,
    meta: {
      isShow: true,
    },
  },
  {
    path: "/Shoppingcart",
    name: "Shoppingcart",
    meta: {
      isShow: true,
    },
    component: Shoppingcart,
    meta: {
      isShow: true,
    },
  },
  {
    path: "/login",
    name: "Login",
    component: Login,
    meta: {
      isShow: false,
    },
  },

  {
    path: "/Details/:id",
    name: "Details",
    meta: {
      isShow: false,
    },
    component: Details,
    props: true,
  },
  //搜索
 { path: "/Search", name: "Search", component: Search, meta: {
    isShow: false,
  }, 
},
  //注册
  {
    path: "/reg",
    name: "reg",
    component: reg,
  },
  {
    path: "/Search",
    name: "Search",
    component: Search,
    meta: {
      isShow: false,
    },
  },
  {
    path: "/Searchlist",
    name: "Searchlist",
    component: Searchlist,
    meta: {
      isShow: false,
    },
  },

  // {
  //   path: "/about",
  //   name: "About",
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () =>
  //     import(/* webpackChunkName: "about" */ "../views/About.vue"),
  // },
];
  //全局前置守卫
  // router.beforeEach((to,from,next)=>{
  //   NProgress.start()
  //   if(to.path=='/login'){
  //     return next()
  //   }
  //   //如果不是去登录,就要查看是否携带token
  //   const token=sessionStorage.getItem("token");
  //   if(!token){
  //     return next ("/login")
  //   }
  //   return next()
  // })


const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

export default router;
